﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PyroGen;

namespace PyroGenTest
{
  
    [TestClass]
    public class CodeConfigHandlerTest
    { 
        [TestMethod]
        public void CodeConfigHandlerEmpty()
        {
            string str = "";
            ConfigHandler cfh = new ConfigHandler(str);
            
            List<string> vals = cfh.FindValuesOfConfig("bar");
            Assert.AreEqual(0, vals.Count);

        }


        [TestMethod]
        public void CodeConfigHandlerSimple()
        {
            string str = " bar=\"foo\" one=\"two\"";
            ConfigHandler cfh = new ConfigHandler(str);
            List<string> vals = cfh.FindValuesOfConfig("bar");
            Assert.AreEqual(1, vals.Count);
            Assert.AreEqual("foo", vals[0]);

            vals = cfh.FindValuesOfConfig("one");
            Assert.AreEqual(1, vals.Count);
            Assert.AreEqual("two", vals[0]);

            vals = cfh.FindValuesOfConfig("tri");
            Assert.AreEqual(0, vals.Count);

        }


        [TestMethod]
        public void CodeConfigHandlerTwoVal()
        {
            string str = " one=\"foo\" notone=\"foo\" one=\"two\" one=\"tri\"";
            ConfigHandler cfh = new ConfigHandler(str);
            List<string> vals = cfh.FindValuesOfConfig("one");

            Assert.AreEqual(3, vals.Count);
            Assert.AreEqual("foo", vals[0]);
            Assert.AreEqual("two", vals[1]);
            Assert.AreEqual("tri", vals[2]);
        }
 /* */
    }
     
}
